package com.bltec.emergency.mapper;


import com.bltec.emergency.model.ForeignVesselNumber;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface ForeignVesselNumberMapper {
    //插入一条ForeignVesselNumber记录
    @Insert("insert into foreign_vessel_number (ship_name,daily_fee,fuel_price,rescue_area,rescue_begin_time,rescue_end_time,rescue_fuel,rescue_num," +
            "create_by,create_time,enable) " +
            "values(#{shipName},#{dailyFee},#{fuelPrice},#{rescueArea},#{rescueBeginTime},#{rescueEndTime},#{rescueFuel},#{rescueNum}," +
            "#{createBy},#{createTime},#{enable})")
    boolean insert(ForeignVesselNumber foreignVesselNumber);

    //通过id设置一条记录为不可用
    @Update("update foreign_vessel_number set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update foreign_vessel_number set ship_name=#{shipName},daily_fee=#{dailyFee},fuel_price=#{fuelPrice},rescue_area=#{rescueArea}," +
            "rescue_begin_time=#{rescueBeginTime},rescue_end_time=#{rescueEndTime},rescue_fuel=#{rescueFuel},rescue_num=#{rescueNum}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateForeignVesselNumberById(ForeignVesselNumber foreignVesselNumber);

    //查找符合id字段的记录
    @Select("select id,ship_name,daily_fee,fuel_price,rescue_area,rescue_begin_time,rescue_end_time,rescue_fuel,rescue_num," +
            "create_by,create_time,update_by,update_time,enable" +
            " from foreign_vessel_number where id =#{id} and enable=1")
    ForeignVesselNumber getForeignVesselNumberById(Long id);

    //查找所有记录
    @Select("select id,ship_name,daily_fee,fuel_price,rescue_area,rescue_begin_time,rescue_end_time,rescue_fuel,rescue_num," +
            "create_by,create_time,update_by,update_time,enable" +
            " from foreign_vessel_number where enable=1")
    List<ForeignVesselNumber> selectAll();
}